home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Newton / newt-23 / dos / applic0.nwt next >
Encoding:
Text File  |  1994-10-01  |  3.2 KB  |  120 lines  |  [TEXT/R*ch]

  1. Notes
  2. {labels: 'nil, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business.  remove viewFont for current Styles default
  3. //ERASE! in order to erase existing entries in this folder first
  4.  
  5. applic0.nwt -- Slurpee format
  6. 8/20/94
  7. Copyright 1994 S. Weyer.  All Rights Reserved Worldwide.
  8. To be distributed only with Newt 2.3 package
  9.  
  10. A simple introduction to creating applications with Newt. This is a variation
  11. on a version described in article "Building Native Newton Applications with
  12. Newt" in PIE Developers, July 1994. see also NewtATut.
  13.  
  14. To minimize text entry, use the Slurpee utility and a terminal emulator to
  15. transfer this text file as paragraphs in the Notepad.  The folder in 2nd line
  16. is currently set on nil (Unfiled); select same folder in Newt to load.
  17.  
  18. Tap Expr button, select expression :doObj('add, 'MyApp).
  19. Tap Eval, select MyApp, then select each subsequent object in list
  20. to create application incrementally.  See NewtNews.txt.  See also NewtATut
  21.  
  22. ----------
  23. MyApp
  24. //:doObj('add,'MyApp)
  25. {_proto: 'protoApp,
  26. //viewBounds -- defaults to full screen
  27. title: "Hello World",
  28. }
  29. ----------
  30. MyApp.myInputProto
  31. {_proto: 'protoInputLine,
  32. text: "",
  33. value: 0,
  34. viewFlags: 10753, //vVisible + vClickable + vGesturesAllowed + vNumbersAllowed,
  35. getTextValue: func() // from text, set number value (used by total)
  36.     begin
  37.     self.value := StringToNumber(text);
  38.     if not value then value := 0;
  39.     end,
  40. viewChangedScript: func(slot,view)
  41.     if slot='text
  42.     then begin
  43.         :getTextValue();
  44.         if total exists then total:update();
  45.         end,
  46. viewSetupFormScript: func()
  47.     begin
  48.     self.text := clone(text);
  49.     :getTextValue();
  50.     inherited:?viewSetupFormScript();
  51.     end,
  52. }
  53. ----------
  54. MyApp+num1
  55. {_proto: 'myInputProto,
  56. viewBounds: RelBounds(130,20,100,20),
  57. }
  58. ----------
  59. MyApp+num2
  60. {_proto: 'myInputProto,
  61. viewBounds: RelBounds(130,45,100,20),
  62. }
  63. ----------
  64. MyApp+total
  65. {_proto: 'protoStaticText,
  66. viewBounds: RelBounds(130,80,100,16),
  67. text: "Total", // initial text
  68. numVars: ['num1, 'num2],
  69. getValueText: func() // return text from summing field values
  70.     begin
  71.     local tot := 0, field;
  72.     foreach field in numVars // add up num1.value + num2.value etc.
  73.     do tot := tot + GetVariable(self,field).value;
  74.     if round exists and round.viewValue
  75.     then tot := RIntToL(tot);
  76.     NumberStr(tot); // return string
  77.     end,
  78. update: func()
  79.     SetValue(self,'text,:getValueText()),
  80. viewSetupFormScript: func()
  81.     begin
  82.     self.text := :getValueText();
  83.     inherited:?viewSeutpFormScript();
  84.     end,
  85. }
  86. ----------
  87. MyApp+round
  88. {_proto: 'protoCheckbox,
  89. viewBounds: RelBounds(20,78,50,16),
  90. text: "Round?",
  91. valueChanged: func()
  92.     if total exists then total:update(),
  93. }
  94. ---------
  95. MyApp+button
  96. {_proto: 'protoTextButton,
  97. viewBounds: RelBounds(100,120,40,16),
  98. text: "About",
  99. buttonClickScript: func()
  100.     if float exists
  101.     then float:open()
  102.     else PlaySound(@102), // ROM_funbeep
  103. }
  104. ----------
  105. MyApp+float
  106. {_proto: 'protoFloatNGo,
  107. viewBounds: RelBounds(20,140,150,100),
  108. }
  109. ----------
  110. MyApp.float+aboutText
  111. {viewclass: 'clParagraphView,
  112. viewBounds: RelBounds(5,5,140,90),
  113. text: "This demo created by"&&
  114.       userConfiguration.name&
  115.       ", with the help of Newt, the lizard wizard",
  116. viewFlags: 3, //vReadOnly+vVisible,
  117. }
  118. ----------
  119. BYE!
  120.